package cn.mdmbct.douyin.common.http;

import cn.mdmbct.douyin.common.config.HttpConfig;
import cn.mdmbct.douyin.common.http.apache.ApacheHttpExecutorFactory;
import cn.mdmbct.douyin.common.http.okhttp.OkHttpExecutorFactory;

/**
 * @author mdmbct  mdmbct@outlook.com
 * @date 4/25/2021 12:40 PM
 * @modified mdmbct
 * @since 1.0
 */
public class HttpExecutorCreator implements HttpExecutorFactory {

    @Override
    public HttpExecutor createHttpExecutor(HttpConfig httpConfig) {

        switch (httpConfig.getType()) {
            case OK_HTTP:
                return new OkHttpExecutorFactory().createHttpExecutor(httpConfig);
            case APACHE_HTTP:
                return new ApacheHttpExecutorFactory().createHttpExecutor(httpConfig);
            default:
                return new OkHttpExecutorFactory().createHttpExecutor(httpConfig);
        }
    }
}
